package com.quantdo.service;

import java.sql.SQLException;
import java.util.List;

import com.quantdo.pojo.ServerDto;

public class ServerManageService {
	private ServerManageDao dao = new ServerManageDao();
	
	public static void main(String[] args) throws SQLException {
		ServerDto serverDto = new ServerDto();
		serverDto.setId(1);
		serverDto.setServerAddr("127.0.0.1");
		serverDto.setUserName("username");
		serverDto.setPassword("password");
		
		ServerManageService manageService = new ServerManageService();
		System.out.println(manageService.getServerList());
		System.out.println(manageService.get(serverDto));
		System.out.println(manageService.save(serverDto));
		System.out.println(manageService.delete(serverDto));
	}

	public List<ServerDto> getServerList() throws SQLException {
		return dao.selectList();
	}
	
	public ServerDto get(ServerDto serverDto) throws SQLException {
		return dao.getByDto(serverDto);
	}
	
	public boolean save(ServerDto serverDto) throws SQLException {
		return dao.insert(serverDto);
	}
	
	public boolean delete(ServerDto serverDto) throws SQLException {
		return dao.delete(serverDto);
	}
}
